﻿using mscook.core.domain;
using mscook.core.repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mscook.core.services
{
    public class CookBookService : ICookBookService
    {
        private ICookBookRepository iCookBookRepository;
        private IResourceTypeRepository iResourceTypeRepository;

        public CookBookService(ICookBookRepository iCookBookRepository, IResourceTypeRepository iResourceTypeRepository)
        {
            this.iCookBookRepository = iCookBookRepository;
            this.iResourceTypeRepository = iResourceTypeRepository;
        }

        public void SaveOrUpdate(CookBook CookBook)
        {
            iCookBookRepository.SaveOrUpdate(CookBook);
        }

        public CookBook Get(string id)
        {
            return iCookBookRepository.Get(id);
        }

        public IList<CookBook> SelectPageList(int start, int limit, out long total)
        {
            return iCookBookRepository.SelectPageList(start, limit, out  total);
        }

        public bool Delete(string id)
        {
            return iCookBookRepository.Delete(id);
        }
        public IList<CookBook> SelectListShowOnHome()
        {
            return iCookBookRepository.GetAll();
        }

        public IList<CookBook> SelectListShowOnHome3D()
        {
            return iCookBookRepository.GetAll();
        }

        public IList<CookBook> SelectLimitbyIds(IList<string> resourceIds,int start,int limit,out long total)
        {
            return iCookBookRepository.GetLimitByIds(resourceIds,start,limit,out total);
        }

        public IList<CookBook> GetAll()
        {
            return iCookBookRepository.GetAll();
        }

        public IList<CookBook> GetByKeyword(string keyword, int start, int limit, out long total)
        {
            return iCookBookRepository.GetByKeyword(keyword,start,limit,out total);
        }

        public IList<CookBook> SelectPageList(int start, int limit, out long total, string cookBookName)
        {
            return iCookBookRepository.SelectPageList(start,limit,out total,cookBookName);
        }
        public IList<CookBook> SelectPageListByExpressions(int start, int limit, out long total, System.Linq.Expressions.Expression<Func<CookBook, bool>> expression)
        {
            return iCookBookRepository.SelectPageList(start, limit, out total, expression);
        }
    }
}
